package homework.util.observer;

import java.util.LinkedList;
import java.util.List;

public abstract class Observable {

    List<Observer> observers = new LinkedList<Observer>();

    public boolean addObserver(Observer observer) {
        return observers.add(observer);
    }

    public boolean removeObserver(Observer observer) {
        return observers.remove(observer);
    }

    public Observer removeObserver(int i) {
        return observers.remove(i);
    }

    public void notifyObservers(Object msg) {
        for(Observer o: observers) {
            o.receive(this, msg);
        }
    }
}
